#include "auth_pkg.h"
#include "assert.h"
#include <string>
#include "const.h"
#include "log_mgr.h"
#include "my_sql_parse.h"

AuthPkg::AuthPkg()
:m_cs(0)
{
	;
}

AuthPkg::~AuthPkg()
{
	;
}

Result AuthPkg::Parse(Context* pCtx)
{
	assert(pCtx->pMysql->proto == REQ_AUTH);
	assert(pCtx->pMysql->pBuff);

	Result ret = OK;
	
	//CLIENT_PROTOCOL_41, charset offset = 8;
	m_cs = *(pCtx->pMysql->pBuff+PKG_HEAD_LEN+8);
	//set to thd ctx
	THD* thd = dynamic_cast<CSqlParser*>(pCtx->pMysql->pParser)->MyTHD();
	if(thd)
	{
		thd_init_client_charset(thd, m_cs);
		thd->update_charset();
	}

	PKG("[%s] [AUTH] [charset:%d]", 
		retDesc[ret], 
		m_cs);
	
	return ret;
}

Result AuthPkg::Check(Context* pCtx)
{
	//todo...
	
	assert(0);
	return OK;
}



